<?php
define('IN_ADMINCP', TRUE);
define('IN_TESTCP', TRUE);
define('TESTCP_AJAX', AJAX);
define('TESTCP_PATH', dirname(__FILE__));
define('APP_PATH', dirname(TESTCP_PATH));
//echo TESTCP_PATH . '--' . APP_PATH;die;
require APP_PATH . '/app.php';
$admincp = new admincp;
$account = new admincp_account;
//上面的代码采用杨坤的框架，下面的代码采用原生PHP
include "center/Model.class.php";
include "center/Route.class.php";
class Index extends Model{
    public $data='';
    public $erroe='';
    public function __construct(){
        //用户权限认证
    }
    public function Action(){
        if(isset($_GET['id'])){
            //var_dump($this->Show($_GET['id']));exit;
            $this->data=$this->Show($_GET['id']);
        }else{
            $this->error='此文章不存在！';
        }
    }
    private function Show($id){
        $sql="SELECT * FROM oa_article WHERE id=$id";
        return parent::one($sql);
    }
}
$model=new Index();
$model->Action();
?>
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>后台管理</title>
    <link rel="stylesheet" type="text/css" href="assets/css/show.css"/>
    <script type="text/javascript" src="assets/js/jquery-1.9.1.min.js"></script>
</head>
<body>
<div id="content">
    <div id="content-box">
        <div class="content-head">
            <div class="keyboard padding-l40">
                <input type="text" class="search padding-l40 color-black" placeholder="站内搜索"/>

            </div>
        </div>
        <div class="content">
            <div class="box-head">
                <span class="width18">文章详情</span>
            </div>
            <div id="list" style="padding:25px; overflow: hidden;">
                <h2 style="font-size: 30px; padding:15px 0;">
                    <?= $model->data["title"];?>
                    <span style="float:right; font-size: 14px; padding-top: 14px; color:#8a95a2;">
                        作者：<?= $model->data["admin"];?>&nbsp;&nbsp;/&nbsp;&nbsp;发布时间：<?= date('Y-m-d',$model->data['create_tim']);?>
                    </span>
                </h2>
                <p><?=$model->data['content'];?></p>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    //复选框点击样式
    var inputs=new Array();
    var id;
    $('.checkbox').on('click',function(){
        a=$(this).children('input').val();
        if(a==0){
            $(this).addClass('checkbox-on');
            $(this).removeClass('checkbox-off');
            $(this).children('input').val(1);
            id=$(this).children('input').attr('name');
        }else{
            $(this).addClass('checkbox-off');
            $(this).removeClass('checkbox-on');
            $(this).children('input').val(0);
            id=$(this).children('input').attr('name');
        }
        if($.inArray(id,inputs)!=-1){
            inputs.splice($.inArray(id,inputs),1);
            console.log(inputs)
        }else{
            inputs.unshift(id);
            console.log(inputs)
        }
    });
    $('#delete-menu').click(function(){
            if(inputs.length==0){
                $('.hint').html('至少选择一条数据!');
                return;
            }
            $.ajax({
                type:'post',
                data:{data:inputs,deletes:'all'},
                url:'<?= Route::Url('index')?>',
                success:function(response,status,xhr){
                    window.location.reload();
                    //console.log(response);
                }
            });
        }
    );
</script>
</body>
</html>